***BKP sample restrictions

*married individuals (spouse present)
keep if marst == 1
	
*own and spouse age restrictions
keep if inrange(age, 18, 65) & inrange(sp_age, 18, 65)

*own or spouse employed (employed)
keep if empstat == 1 |empstat == 2 | sp_empstat == 1 | sp_empstat == 2

*Earnings restrictions
replace spearnweek = 0 if sp_empstat != 1 & sp_empstat != 2

*Not in BKP table notes but in their code
replace earnweek = 0 if empstat != 1 & empstat != 2

replace spearnweek=. if spearnweek<0 | spearnweek>3000
replace earnweek=. if earnweek<0 | earnweek>3000

replace earnweek=1.5*earnweek if earnweek==2884.61
replace spearnweek=1.5*spearnweek if earnweek==2884.61

drop if marst==1 & sp_female==female


***Redefine relative earnings variable

*relative income
drop relinc
gen relinc = 0
replace relinc = earnweek/(earnweek + spearnweek) if female == 1
replace relinc = spearnweek/ (earnweek + spearnweek) if female == 0

replace relinc=0 if female==1 & empstat>2 & spearnweek>0 & spearnweek!=.
replace relinc=0 if female==0 & sp_empstat>2 & earnweek>0 & earnweek!=.
replace relinc=1 if female==1 & sp_empstat>2 & earnweek>0 & earnweek!=.	
replace relinc=1 if female==0 & empstat>2 & spearnweek>0 & spearnweek!=.	

la var relinc "Relative Income"

cap drop rel02
cap drop rel12

gen rel02=relinc==0
gen rel12=relinc==1


*Make the weight variable (each year to have equal weight)
egen sumwt=sum(wt06), by(year)
gen newwt=wt06/sumwt	
	
label var newwt "Adjusted ATUS Weight"